package de.fhb.itunes.manager.mail;

import java.util.ArrayList;
import java.util.List;

import de.fhb.itunes.manager.Config;
import de.fhb.itunes.manager.mail.Template.Template;



public class MailContentBuilder {

	private String header;
	private String footer;
	private String content;
	private List<Template> htmlTeile;

	public MailContentBuilder() {
		Config config = new Config();

		this.footer = Helper_File.ladeDatei(config.getProperties().getProperty(
				"pfad_footer"));
		this.header = Helper_File.ladeDatei(config.getProperties().getProperty(
				"pfad_header"));
		this.content = "";
		htmlTeile = new ArrayList<Template>();
	}

	public MailContentBuilder(String header, String footer) {
		this.header = header;
		this.footer = footer;
		htmlTeile = new ArrayList<Template>();
	}

	private void savemail(String inhalt) {
		Helper_File.speichereInDatei(inhalt);
	}

	public void addTemplate(Template template) {
		this.htmlTeile.add(template);
	}

	public String getEmail() {
		String senden = content;
		for (Template temp : htmlTeile) {
			senden += temp.getHTML();
		}
		String mail = header + senden + footer;
		savemail(mail);
		return mail;

	}

	public String getHeader() {
		return header;
	}

	public void setHeader(String header) {
		this.header = header;
	}

	public String getFooter() {
		return footer;
	}

	public void setFooter(String footer) {
		this.footer = footer;
	}

}
